package com.juc.atomic;

import java.util.concurrent.CountDownLatch;

/**
 * @Author HK
 * @Date 2022/5/21 17:41
 * @Version 1.0
 */
public class AtomicIntegerDemo {


    public static final int SIZE = 50;

    public static void main(String[] args) throws InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(SIZE);

        for (int i = 0; i < SIZE; i++) {
            new Thread(() ->{
                try {
                    for (int j = 0; j < 100; j++) {

                    }
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    countDownLatch.countDown(); //-
                }
            },String.valueOf(i)).start();
        }
        countDownLatch.await(); //取消等待阻塞
    }
}


